<!-- 交易佣金标准 新建编辑 -->

<template>
    <div class="transactionCommissionHandle">
        <el-breadcrumb v-if="!viewDetailReceiveId" separator="/" class="bread-title">
            <el-breadcrumb-item :to="{ path: '/transactionCommission' }">交易佣金标准</el-breadcrumb-item>
            <el-breadcrumb-item>{{typeMap[type]}}</el-breadcrumb-item>
        </el-breadcrumb>

        <div v-if="type=== 'view'">
            <div>提取标准：成交结算</div>
            <h3>业务佣金分配金额</h3>
            <div>业务佣金比例：{{dealAllot.businessComm}}% <span class="ml50 mr50"></span>公佣佣金比例：{{dealAllot.publicComm}}%
            </div>
            <h3>计提节点</h3>
            <div v-for="(item, index) in dealAllot.nodeList" :key="index">
                {{item.projectLevelName}}: {{item.calculateNodeNames}}
            </div>
            <h3>计提比例</h3>
            <el-tabs type="border-card" class="mt20" v-model="levelName">
                <el-tab-pane v-for="(item,index) in dealAllot.headerList" :key="index" :label="item.developerName + ' - ' +item.projectLevelName" :name="item.developerName + ' - ' +item.projectLevelName">
                    <el-table
                            :data="dealAllot.dataList[index].proList"
                            border
                            style="width: 100%">
                        <el-table-column
                                v-for="(subItem, subIndex) in item.labelList"
                                :label="subItem.label"
                                :key="subIndex"
                        >
                            <template slot-scope="scope">{{scope.row[subItem.props] &&
                                (scope.row[subItem.props]+"").split("|")[0]}}
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
            </el-tabs>
            <h3>业务佣金发放</h3>

            <el-table
                    border
                    :data="dealAllot.roleList"
                    style="width: 100%">
                <el-table-column
                        type="index"
                        align="center"
                        label="序号"
                        width="80">
                </el-table-column>
                <el-table-column
                        prop="typeName"
                        align="center"
                        label="角色">
                </el-table-column>
                <el-table-column
                        prop="totalProportion"
                        align="center"
                        label="发放总比例">
                    <template slot-scope="scope">{{scope.row.totalProportion}}%</template>
                </el-table-column>
                <el-table-column
                        prop="monthProportion"
                        align="center"
                        label="月度发放比例">
                    <template slot-scope="scope">{{scope.row.monthProportion}}%</template>
                </el-table-column>
                <el-table-column
                        prop="yearProportion"
                        align="center"
                        label="年度发放比例">
                    <template slot-scope="scope">{{scope.row.yearProportion}}%</template>
                </el-table-column>
            </el-table>

            <h3>公佣发放</h3>
            <el-table
                    :data="dealAllot.departList"
                    border
                    style="width: 100%">
                <el-table-column
                        type="index"
                        align="center"
                        label="序号"
                        width="80">
                </el-table-column>
                <el-table-column
                        prop="typeName"
                        align="center"
                        label="部门">
                </el-table-column>
                <el-table-column
                        align="center"
                        label="分配比例（%）">
                    <template slot-scope="scope">
                        {{scope.row.totalProportion}}%
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div v-else>
            <div v-if="stepIndex === 0">
                <h3>请选择套餐类型</h3>
                <hr/>
                <el-button class="mt20" type="primary" icon="el-icon-plus" @click="selectDialog(true)">选择标准</el-button>

                <div class="selectedType" v-if="currentStandard.id">
                    <div>提取标准：{{extractStandard[currentStandard.extractStandard]}}</div>
                    <div>佣金来源：{{commSource[currentStandard.commSource]}}</div>
                    <div>提取规则：{{currentStandard.ruleList | extractCategoryFilter}}</div>
                    <div>版 &nbsp; &nbsp; &nbsp; 本：{{currentStandard.version}}</div>
                </div>

                <div class="mt50">
                    <el-button class="mt20" @click="returnList">取消</el-button>
                    <el-button class="mt20" type="primary" @click="changeStepIndex(1)">下一步</el-button>
                </div>

                <el-dialog
                        title="选择标准"
                        :visible.sync="selectDialogVisible"
                        width="40%">
                    <div>
                        <el-row :span="24" :gutter="20">
                            <el-col :span="18">
                                <el-input
                                        placeholder="请输入版本号"
                                        prefix-icon="el-icon-search"
                                        size="normal"
                                        v-model="selectDialogInputValue">
                                </el-input>
                            </el-col>
                            <el-col :span="6">
                                <el-button size="normal" type="primary" @click="getTransactionSettlementList">查询
                                </el-button>
                            </el-col>

                        </el-row>

                        <div class="mt20" style="height: 300px; overflow: auto;">
                            <div class="selectedInterval-item" v-for="(item, index) in dialogList" :key="index">
                                <el-radio v-model="selectedInterval" :label="item.id">
                                    <div>提取标准：{{extractStandard[item.extractStandard]}}</div>
                                    <div>佣金来源：{{commSource[item.commSource]}}</div>
                                    <div>提取规则：{{item.ruleList | extractCategoryFilter}}</div>
                                    <div>版 &nbsp; &nbsp; &nbsp; 本：{{item.version}}</div>
                                    <el-button type="text" class="viewDetail" @click="viewDetail(item.id)">查看详情
                                    </el-button>
                                </el-radio>
                            </div>
                        </div>
                    </div>
                    <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="selectDialog(false)">选 择</el-button>
                <el-button @click="selectDialogVisible = false">取 消</el-button>
            </span>
                </el-dialog>
            </div>
            <div v-else>
                <div>提取标准：成交结算</div>
                <h3>业务佣金分配金额</h3>
                <div>
                    * 业务佣金比例
                    <el-input class="w100 ml10 mr10" size="mini" v-model="dealAllot.businessComm" @input="replaceCommProportion(dealAllot.businessComm, 'businessComm', 'publicComm')"></el-input>
                    %
                    <i style="display: inline-block" class="ml50 mr50"></i>
                    * 公佣佣金比例
                    <el-input class="w100 ml10 mr10" size="mini" v-model="dealAllot.publicComm" @input="replaceCommProportion(dealAllot.publicComm, 'publicComm', 'businessComm')"></el-input>
                    %
                </div>
                <el-tabs type="border-card" class="mt20" v-model="levelName" @tab-click="handleTabsClick">
                    <el-tab-pane v-for="(item,index) in dealAllot.headerList" :key="index" :label="item.developerName+ ' - ' + item.projectLevelName" :name="item.developerName+ ' - ' + item.projectLevelName">
                        <el-table
                                :data="dealAllot.dataList[index].proList"
                                border
                                style="width: 100%">
                            <el-table-column
                                    v-for="(subItem, subIndex) in item.labelList"
                                    :label="subItem.label"
                                    :key="subIndex"
                            >
                                <template slot-scope="scope">
                                    <span v-if="subIndex < 2">{{scope.row[subItem.props] && (scope.row[subItem.props]+"").split("|")[0]}}</span>
                                    <el-input v-else v-model="scope.row[subItem.props]" @input="replaceProjectLevelProportion(scope.row[subItem.props], index, scope.$index, subItem.props, item.extractCategory)" size="mini"></el-input>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-tab-pane>
                </el-tabs>

                <hr class="mt30 mb30"/>

                <el-tabs type="border-card" class="mt20" v-model="commissionName" @tab-click="handleTabsClick">
                    <el-tab-pane label="业务佣金分配" name="业务佣金分配">
                        <div class="commissionTab1">
                            <span>* 角色：</span>
                            <el-select v-model="bc.roleValue" placeholder="请选择">
                                <el-option
                                        v-for="item in roleOptions"
                                        :key="item.id"
                                        :label="item.roleName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
                        </div>
                        <div class="commissionTab1">
                            <span>* 发放总比例：</span>
                            <el-input class="w200" v-model="bc.totalProportion" @input="replaceBusinessProportion(bc.totalProportion, 'totalProportion')" placeholder="请输入内容"></el-input>
                            %
                        </div>
                        <div class="commissionTab1">
                            <span>* 其中：</span>
                            月度比例：
                            <el-input class="w200" v-model="bc.monthProportion" @input="replaceBusinessProportion(bc.monthProportion, 'monthProportion', 'yearProportion')" placeholder="请输入内容"></el-input>
                            %
                        </div>
                        <div class="commissionTab1">
                            <span></span>
                            年度比例：
                            <el-input class="w200" v-model="bc.yearProportion" @input="replaceBusinessProportion(bc.yearProportion, 'yearProportion', 'monthProportion')" placeholder="请输入内容"></el-input>
                            %
                        </div>
                        <div class="commissionTab1">
                            <span></span>
                            <el-button type="primary" icon="el-icon-plus" @click="addBusinessSettingList">添加</el-button>
                        </div>
                        <div>
                            <hr class="mt30 mb30"/>
                            <el-table
                                    border
                                    :data="dealAllot.roleList"
                                    style="width: 100%">
                                <el-table-column
                                        type="index"
                                        align="center"
                                        label="序号"
                                        width="80">
                                </el-table-column>
                                <el-table-column
                                        prop="typeName"
                                        align="center"
                                        label="角色">
                                </el-table-column>
                                <el-table-column
                                        prop="totalProportion"
                                        align="center"
                                        label="发放总比例">
                                    <template slot-scope="scope">{{scope.row.totalProportion}}%</template>
                                </el-table-column>
                                <el-table-column
                                        prop="monthProportion"
                                        align="center"
                                        label="月度发放比例">
                                    <template slot-scope="scope">{{scope.row.monthProportion}}%</template>
                                </el-table-column>
                                <el-table-column
                                        prop="yearProportion"
                                        align="center"
                                        label="年度发放比例">
                                    <template slot-scope="scope">{{scope.row.yearProportion}}%</template>
                                </el-table-column>
                                <el-table-column
                                        prop="yearProportion"
                                        align="center"
                                        label="操作">
                                    <template slot-scope="scope">
                                        <a href="javascript:;;" @click="delBusinessSettingList(scope.$index)">删除</a>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label="公佣分配比例" name="公佣分配比例">
                        <el-button class="mb20" type="primary" @click="selectDepartment(true)">选择分配部门</el-button>
                        <el-table
                                :data="dealAllot.departList"
                                border
                                style="width: 100%">
                            <el-table-column
                                    type="index"
                                    align="center"
                                    label="序号"
                                    width="80">
                            </el-table-column>
                            <el-table-column
                                    prop="typeName"
                                    align="center"
                                    label="部门">
                            </el-table-column>
                            <el-table-column
                                    align="center"
                                    label="分配比例（%）">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.totalProportion" size="mini" @input="replaceDepartmentProportion(scope.row.totalProportion, scope.$index)"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column
                                    align="center"
                                    label="操作">
                                <template slot-scope="scope">
                                    <a href="javascript:;;" @click="delDepartmentProportion(scope.$index)">删除</a>
                                </template>
                            </el-table-column>
                        </el-table>

                        <el-dialog
                                title="添加部门"
                                :visible.sync="departmentDialogVisible"
                                width="550px"
                        >
                            <el-transfer
                                    filterable
                                    filter-placeholder="请输入城市拼音"
                                    :titles="['全部', '已选中']"
                                    v-model="department"
                                    :props="{
                                   key: 'id',
                                   label: 'departmentName'
                                }"
                                    :data="departmentList">
                            </el-transfer>
                            <span slot="footer" class="dialog-footer">
                            <el-button @click="departmentDialogVisible = false">取 消</el-button>
                            <el-button type="primary" @click="selectedDepartment">确 定</el-button>
                        </span>
                        </el-dialog>
                    </el-tab-pane>
                </el-tabs>

                <div class="mt50">
                    <el-button class="mt20" @click="changeStepIndex(0)">上一步</el-button>
                    <el-button class="mt20" type="primary" @click="save">保存</el-button>
                </div>
            </div>

            <el-dialog
                    title="查看详情"
                    :visible.sync="viewDetailVisible"
                    width="800px">
                <transaction-settlement-handle :viewDetailReceiveId="viewDetailSendId"/>
                <span slot="footer" class="dialog-footer">
                    <el-button @click="viewDetailVisible = false">取 消</el-button>
                </span>
            </el-dialog>
        </div>
    </div>
</template>

<script type="text/ecmascript-6">
    import api from '@/api/apiPath'
    import {extractStandard, commSource, calNode, extractCategory} from '../fieldMap'
    import transactionSettlementHandle from './transactionSettlementHandle'

    export default {
        name: 'transactionCommissionHandle',
        data() {
            return {
                extractStandard, commSource, calNode, extractCategory,
                type: "new",
                typeMap: {
                    new: '新建',
                    edit: '编辑',
                    view: '查看'
                },
                dialogList: [],
                stepIndex: 0,
                selectDialogVisible: false,
                selectDialogInputValue: "",
                selectedInterval: "",
                currentStandard: {},
                levelName: "A级",
                commissionName: "业务佣金分配",

                roleOptions: [],
                roleOptionsMap: {},

                //Business commission    业务佣金  缩写
                bc: {},

                departmentDialogVisible: false,
                department: [],
                departmentList: [],
                departmentListMap: [],

                dealAllot: {
                    headerList: [],
                    calculationNode: 2
                },
                viewDetailVisible: false,
                viewDetailSendId: 0,
            }
        },
        created() {
            this.getAllEffectiveRoleNo();
            this.getAllDepartmentList();

            this.type = this.$route.query.type || 'new';
            if (this.type !== 'new') {
                this.getSingleTC(this.$route.query.id)
            }
        },
        filters: {
            extractCategoryFilter(list) {
                let arr = [];
                list.forEach((item) => {
                    if (!arr.includes(extractCategory[item.extractCategory]))
                        arr.push(extractCategory[item.extractCategory])
                });
                return arr.join(';')
            }
        },
        props: ['viewDetailReceiveId'],
        watch: {
            viewDetailReceiveId: {
                handler(id) {
                    if (id) {
                        setTimeout(() => {
                            this.type = 'view';
                        }, 30)
                        this.getSingleTC(id)
                    }
                },
                immediate: true
            }
        },

        methods: {
            viewDetail(id) {
                this.viewDetailVisible = true;
                this.viewDetailSendId = id;
            },
            selectDialog(flag) {
                if (flag) {
                    this.getTransactionSettlementList()
                }
                this.selectDialogVisible = flag;
                if (!flag && this.selectedInterval) {
                    this.currentStandard = this.dialogList.find((value) => {
                        return value.id === this.selectedInterval
                    });
                    this.getDealBusinessLineRange(this.currentStandard.id)
                }

            },
            changeStepIndex(index) {
                if (index === 1) {
                    if (!this.currentStandard.id) {
                        this.$message({
                            message: '请选择标准！',
                            type: 'warning'
                        });
                        return false;
                    }
                }
                this.stepIndex = index;
            },
            handleTabsClick(tab, event) {
                //console.log(tab, event);
            },
            selectDepartment(type) {
                this.departmentDialogVisible = type;
                if (type) {
                    // 清空选中值
                    this.department = [];

                    if (this.dealAllot.departList && this.dealAllot.departList.length) {
                        let selectArr = []
                        this.dealAllot.departList.forEach((item) => {
                            selectArr.push(item.typeId);
                        })
                        this.departmentList.forEach((item, index) => {
                            this.$set(this.departmentList[index], 'disabled', selectArr.indexOf(item.id) > -1)
                        })
                    } else {
                        this.dealAllot.departList = [];
                        this.departmentList.forEach((item, index) => {
                            this.$set(this.departmentList[index], 'disabled', false)
                        })
                    }
                }
            },
            selectedDepartment() {
                this.department.forEach((item) => {
                    this.dealAllot.departList.push({
                        typeId: item,
                        typeName: this.departmentListMap[item],
                        totalProportion: "",
                    })
                })
                this.departmentDialogVisible = false;
            },
            delDepartmentProportion(index) {
                this.dealAllot.departList.splice(index, 1)
            },
            replaceDepartmentProportion(value, index) {
                value = this.formatTwoDecimal(value, 100);
                setTimeout(() => {
                    this.$set(this.dealAllot.departList[index], 'totalProportion', value)
                }, 30)
            },
            getTransactionSettlementList() {
                this.axios.post(api.getTransactionSettlementList, {
                    version: this.selectDialogInputValue
                }).then((res) => {
                    // console.log(res.data.data.list);
                    this.dialogList = res.data.data.list
                })
            },
            getDealBusinessLineRange(id) {
                this.axios.post(api.getDealBusinessLineRange, {
                    dealId: id
                }).then((res) => {
                    this.dealAllot = res.data.data;
                    this.dealAllot.calculationNode = 2;
                    const headerList = res.data.data.headerList;
                    this.levelName = headerList[0].developerName + ' - ' + headerList[0].projectLevelName;

                    //console.log(this.dealAllot);
                })
            },
            replaceBusinessProportion(value, field1, field2) {
                value = this.formatTwoDecimal(value, 100);
                setTimeout(() => {
                    this.$set(this.bc, field1, value)
                    this.$set(this.bc, field2, 100 - value)
                }, 30)
            },
            replaceCommProportion(value, field1, field2) {
                value = this.formatTwoDecimal(value, 100);
                setTimeout(() => {
                    this.$set(this.dealAllot, field1, value);
                    this.$set(this.dealAllot, field2, 100 - value);
                }, 30)
            },
            formatTwoDecimal(value, maxNumber, isIncludeMax) {
                value = value.replace(/[^\d.]/g, '');
                value = value.replace(/\.{2,}/g, ".");
                value = value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
                value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
                if (value.indexOf('.') < 0 && value != '') {
                    value = parseInt(value);
                }
                // 设置最大限制
                if (maxNumber) {
                    const bool = isIncludeMax ? +value >= maxNumber : +value > maxNumber;
                    if (bool) {
                        let valueString = String(value)
                        value = valueString.slice(0, valueString.length - 1)
                    }
                }
                if (value === '.') {
                    value = '0.'
                }
                return value
            },
            replaceProjectLevelProportion(value, index, subIndex, props, extractCategory) {
                if (extractCategory === 1) {
                    value = this.formatTwoDecimal(value);
                } else {
                    value = this.formatTwoDecimal(value, 100, true);
                }
                setTimeout(() => {
                    this.$set(this.dealAllot.dataList[index].proList[subIndex], props, value);
                }, 30)
            },
            addBusinessSettingList() {
                if (!this.bc.roleValue) {
                    this.$message({
                        message: '请先选择角色',
                        type: 'warning'
                    });
                    return false;
                }
                if (this.bc.totalProportion === '') {
                    this.$message({
                        message: '发放总比例不能为空！',
                        type: 'warning'
                    });
                    return false;
                }
                if (+this.bc.totalProportion > 100) {
                    this.$message({
                        message: '发放总比例不能大于100！',
                        type: 'warning'
                    });
                    return false;
                }

                if (!this.bc.monthProportion && !this.bc.yearProportion) {
                    this.$message({
                        message: '月度比例和年度比例不能为空！',
                        type: 'warning'
                    });
                    return false;
                }

                if (+this.bc.monthProportion < 0 || +this.bc.monthProportion > 100) {
                    this.$message({
                        message: '月度比例和年度比例不能小于0或大于100！',
                        type: 'warning'
                    });
                    return false;
                }

                if (+this.bc.monthProportion + +this.bc.yearProportion !== 100) {
                    this.$message({
                        message: '月度比例+年度比例需等于100%',
                        type: 'warning'
                    });
                    return false;
                }

                if (this.dealAllot.roleList && this.dealAllot.roleList.length) {
                    // 查重
                    let flag = this.dealAllot.roleList.find((item) => {
                        return item.typeId === this.bc.roleValue
                    })
                    if (flag) {
                        this.$message({
                            message: "已有类型规则存在，请重新添加",
                            type: 'warning'
                        });
                        return false;
                    }
                    let count = 0;
                    this.dealAllot.roleList.forEach((item) => {
                        count += +item.totalProportion
                    })
                    if (count + +this.bc.totalProportion > 100) {
                        this.$message({
                            message: "业务佣金发放总比例需小于或等于100%，请确认后添加",
                            type: 'warning'
                        });
                        return false;
                    }
                } else {
                    this.$set(this.dealAllot, 'roleList', []);
                }
                this.dealAllot.roleList.push({
                    "totalProportion": +this.bc.totalProportion,//发放总比例
                    "monthProportion": +this.bc.monthProportion,//月度比例
                    "yearProportion": +this.bc.yearProportion,//年度比例
                    "typeId": this.bc.roleValue,//角色id
                    "typeName": this.roleOptionsMap[this.bc.roleValue]//角色名称
                })
                this.bc = {};
            },
            delBusinessSettingList($index) {
                this.dealAllot.roleList.splice($index, 1)
            },
            getAllEffectiveRoleNo() {
                this.axios.post(api.getAllEffectiveRoleNo, {}).then((res) => {
                    this.roleOptions = res.data.data;
                    let roleOptionsMap = {};
                    this.roleOptions.forEach((item) => {
                        roleOptionsMap[item.id] = item.roleName;
                    })
                    this.roleOptionsMap = roleOptionsMap
                })
            },
            getAllDepartmentList() {
                this.axios.post(api.getAllDepartmentList, {}).then((res) => {
                    let departmentListMap = {};
                    this.departmentList = res.data.data;
                    this.departmentList.forEach((item) => {
                        departmentListMap[item.id] = item.departmentName
                    })
                    this.departmentListMap = departmentListMap;
                })
            },
            save() {
                // 业务佣金比例和公佣佣金判断
                if (+this.dealAllot.businessComm < 0 || +this.dealAllot.businessComm > 100) {
                    this.$message({
                        message: '业务佣金比例和公佣佣金比例不能小于0或大于100！',
                        type: 'warning'
                    });
                    return false;
                }

                if (+this.dealAllot.businessComm + +this.dealAllot.publicComm !== 100) {
                    this.$message({
                        message: '业务佣金比例和公佣佣金比例相加必须为100！',
                        type: 'warning'
                    });
                    return false;
                }
                let params = {
                    dealId: this.currentStandard.id,
                    businessComm: +this.dealAllot.businessComm,
                    publicComm: +this.dealAllot.publicComm,
                    //calculationNode: this.dealAllot.calculationNode
                };
                //业务佣金
                let busiSettingList = [];
                let busiSettingListCount = 0
                if (this.dealAllot.roleList && this.dealAllot.roleList.length) {
                    this.dealAllot.roleList.forEach((item) => {
                        busiSettingList.push({
                            totalProportion: item.totalProportion,
                            monthProportion: item.monthProportion,
                            yearProportion: item.yearProportion,
                            typeId: item.typeId,
                            type: 1
                        })
                        busiSettingListCount += +item.totalProportion;
                    })
                } else {
                    this.$message({
                        message: '请设置业务佣金分配规则',
                        type: 'warning'
                    });
                    return false;
                }

                if (busiSettingListCount !== 100) {
                    this.$message({
                        message: '业务佣金发放总比例必须为100%',
                        type: 'warning'
                    });
                    return false;
                }
                params.busiSettingList = busiSettingList;
                // 公佣
                let commonSettingList = [];
                let commonSettingListCount = 0;

                if (this.dealAllot.departList && this.dealAllot.departList.length) {
                    this.dealAllot.departList.forEach((item) => {
                        commonSettingList.push({
                            totalProportion: item.totalProportion,
                            typeId: item.typeId,
                            type: 2
                        })
                        commonSettingListCount += +item.totalProportion;
                    })
                } else {
                    this.$message({
                        message: '请设置公佣分配规则',
                        type: 'warning'
                    });
                    return false;
                }

                if (commonSettingListCount !== 100) {
                    this.$message({
                        message: '公佣发放总比例必须为100%',
                        type: 'warning'
                    });
                    return false;
                }
                params.commonSettingList = commonSettingList;

                let projectLevelList = [];
                this.dealAllot.dataList.forEach((item1) => {
                    let rangeList = []
                    item1.proList.forEach((item2) => {
                        let businessLineList = [];
                        for (let keys in item2) {
                            if (keys > 0) {
                                businessLineList.push({
                                    businessLineId: keys,
                                    amount: item2[keys],
                                })
                            }
                        }
                        rangeList.push({
                            rangeDetailId: item2[-2].split("|")[1],
                            businessLineList: businessLineList,
                        })
                    });
                    projectLevelList.push({
                        projectLevelId: item1.projectLevelId,
                        rangeId: item1.rangeId,
                        rangeList: rangeList
                    })
                });
                params.projectLevelList = projectLevelList;
                this.axios.post(api.createDealAllot, params).then((res) => {
                    if (res.data.code === 200) {
                        this.$message({
                            message: this.typeMap[this.type] + "成功",
                            type: 'success'
                        });
                        this.returnList();
                    }
                })
            },
            getSingleTC(id) {
                let currentData = {}
                this.axios.post(api.viewDealAllot, {
                    dealAllotId: id
                }).then((res) => {
                    currentData = res.data.data;
                    return this.axios.post(api.getTransactionSettlementList, {
                        version: currentData.version
                    })
                }).then((res) => {
                    this.currentStandard = res.data.data.list[0];
                    this.dealAllot = currentData;
                    this.dealAllot.calculationNode = 2;
                    this.levelName = currentData.headerList[0].developerName + ' - ' + currentData.headerList[0].projectLevelName;
                })

            },
            returnList() {
                this.$router.push({path: "./transactionCommission"})
            },
        },
        components: {
            transactionSettlementHandle
        },
        computed: {}
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="stylus">
    .selectedInterval-item {
        padding: 0 20px;
        position: relative;
        label {
            display: flex;
            align-items: center;
            > span {
                display: inline-block;
                margin-top: 20px;
                > div {
                    margin: 10px 0;
                }
            }
        }
        .selectedInterval-item-row {
            line-height: 25px;
        }
        .viewDetail {
            position: absolute;
            right: 0;
            top: 50%;
            margin-top: -20px;
        }
    }

    .selectedType {
        padding: 20px;
        margin: 20px 0;
        font-size: 14px;
        border: 1px solid #ccc;
        width: 200px;
        div {
            margin: 5px 0;
        }
    }

    .transactionCommissionHandle {

    }

    .commissionTab1 {
        margin: 20px 0;
        > span {
            width: 120px;
            display: inline-block;
        }
    }

</style>
